package com.lida.auto.config;

import com.lida.auto.business.LogicService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * author: lida
 * create time: 2020-09-01 16:48
 * description:
 */
@Configuration
//这个条件注解的意思是：当前的类路径下 必须得有这个类的时候才会进行自动配置
@ConditionalOnClass(value = LogicService.class)
@EnableConfigurationProperties(value = LogicServiceProperties.class)
public class LogicServiceAutoConfiguration {

    @Bean
    public LogicService generateLogicService(LogicServiceProperties properties) {
        System.out.println(properties);
        return new LogicService(properties.getId(), properties.getPwd());
    }
}
